package com.tianbo.elfii.client.common;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


import com.tianbo.elfii.client.common.ElfiiCommonUtil.FeedBackType;
import com.tianbo.elfii.client.common.wlanmanagement.BaseDialogPane;


public class CalibrationPane extends BaseDialogPane {

	public Container contentPane = null; 
	public CalibrationDialog dialog = null; 

	public CalibrationPane(int type) {
		super();
		// TODO Auto-generated constructor stub
		
		initCalibrationDialog(type);
		
		dialog.setOpaque(false);
	}
	
	public void init(){
		
	}
	
	public void initCalibrationDialog(int type){
		dialog = new CalibrationDialog();
		dialog.setBounds(240, 248, 545, 272);
		dialog.init(type);
		dialog.confirmBtn.addActionListener(new ConfirmBtnListener());
		dialog.cancelBtn.addActionListener(new CancelBtnListener());
		this.add(dialog);
	}

	public class CancelBtnListener implements ActionListener {

		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			mainFrame.setContentPane(contentPane);
			ElfiiCommonUtil.playFeedbackAudio(FeedBackType.CLICK);
		}
	}
	
	
	public class ConfirmBtnListener implements ActionListener {

		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			int type = 4;
			
			if(dialog.ninePointCal.isSelected()){
				type = 9;
			}

			ElfiiCommonUtil.playFeedbackAudio(FeedBackType.CLICK);
			
			ElfiiCommonConfigUtil.doCalibration(type);
			
			mainFrame.setContentPane(contentPane);
		}
	}


}
